home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / cenvid / dosintr.lib < prev    next >
Text File  |  1995-09-27  |  4KB  |  134 lines

  1. // DosIntr.lib - Dos interrupt calls.  These functions are provide
  2. // ver.5         interfaces to some of the low-level DOS calls.
  3. //               This library can be used with CEnvi for DOS or
  4. //               CEnvi for Windows.
  5. //
  6. //**** CreateDirectory(): Create a directory
  7. // SYNTAX: bool CreateDirectory(string DirectorySpec)
  8. // WHERE: DirectorySpec is the name of the directory to create
  9. // RETURN: Return False if error (cannot create or already exists)
  10. // EXAMPLE: CreateDirectory("C:\\TESTDIR");
  11. // NOTE: Use Directory() function to test if directory exists
  12. //
  13. //**** DeleteDirectory(): Delete a directory
  14. // SYNTAX: bool DeleteDirectory(string DirectorySpec)
  15. // WHERE: DirectorySpec is the name of the directory to delete
  16. // RETURN: Return False if error (cannot delete or no directory exists)
  17. // EXAMPLE: DeleteDirectory("C:\\TESTDIR");
  18. //
  19. //**** SetCurrentDirectory(): Change drive to different directory
  20. // SYNTAX: bool SetCurrentDirectory(string DirectorySpec)
  21. // WHERE: DirectorySpec is the name of an existing directory
  22. // RETURN: Return False if error
  23. // EXAMPLE: SetCurrentDirectory("C:\\TESTDIR");
  24. // NOTE: If DirectorySpec includes drive letter, then will not change
  25. //       current drive to that drive; see SetCurrentDrive().  For
  26. //       getting current directory use FullPath(".")
  27. //
  28. //**** SetCurrentDrive(): Change to a different drive letter
  29. // SYNTAX: bool SetCurrentDirectory(char DriveLetter)
  30. // WHERE: DriveLetter is character drive letter to change to
  31. // RETURN: Return False if unable to change to drive letter
  32. // EXAMPLE: SetCurrentDrive('C');
  33. // NOTE: Current drive letter is FullPath(".")[0]
  34. //
  35. //**** SetFileAttributes(): Set File Attributes
  36. // SYNTAX: bool SetFileAttributes(string FileName,int Attributes)
  37. // WHERE: FileName: name of existing file
  38. //        Atrribute: OR of flags as defined in the Directory() function
  39. // RETURN: Return false for failure
  40. // NOTE: Use Directory() to read file attributes; this call does not
  41. //       access volumes or subdirectories; Normal attribute is 0
  42. //
  43. //**** SetFileDateAndTime(): set time and date of last write
  44. // SYNTAX: bool SetFileDateAndTime(string FileName,int Time)
  45. // WHERE: FileName: name of existing file
  46. //        Time: as returned by the time() call or by Directory()
  47. // RETURN: Return false for failure
  48. //
  49.  
  50. CreateDirectory(pDirSpec)
  51. {
  52.    lReg.ah = 0x39;
  53.    if !defined(_DOS32_)
  54.       lReg.ds = segment(pDirSpec), lReg.dx = offset(pDirSpec);
  55.    else
  56.       lReg.dx = pointer(pDirSpec);
  57.    return interrupt(0x21,lReg);
  58. }
  59.  
  60. DeleteDirectory(pDirSpec)
  61. {
  62.    lReg.ah = 0x3A;
  63.    if !defined(_DOS32_)
  64.       lReg.ds = segment(pDirSpec), lReg.dx = offset(pDirSpec);
  65.    else
  66.       lReg.dx = pointer(pDirSpec);
  67.    return interrupt(0x21,lReg);
  68. }
  69.  
  70. SetCurrentDirectory(pDirSpec)
  71. {
  72.    lReg.ah = 0x3B;
  73.    if !defined(_DOS32_)
  74.       lReg.ds = segment(pDirSpec), lReg.dx = offset(pDirSpec);
  75.    else
  76.       lReg.dx = pointer(pDirSpec);
  77.    return interrupt(0x21,lReg);
  78. }
  79.  
  80. SetCurrentDrive(pDriveLetter)
  81. {
  82.    lReg.ah = 0x0E;
  83.    lReg.dl = toupper(pDriveLetter) - 'A';
  84.    interrupt(0x21,lReg);
  85.    return ( (lFullP = FullPath(".")) && lFullP[0] == toupper(pDriveLetter) );
  86. }
  87.  
  88. SetFileAttributes(pFileName,pAttributes)
  89. {
  90.    lReg.ah = 0x43;
  91.    lReg.al = 1;
  92.    lReg.cx = pAttributes;
  93.    if !defined(_DOS32_)
  94.       lReg.ds = segment(pFileName), lReg.dx = offset(pFileName);
  95.    else
  96.       lReg.dx = pointer(pFileName);
  97.    return interrupt(0x21,lReg);
  98. }
  99.  
  100. SetFileDateAndTime(pFileName,pTime)
  101. {
  102.    lSuccess = False;
  103.    // Open file to get a handle
  104.    lReg.ah = 0x3D;
  105.    lReg.al = 0x42;
  106.    if !defined(_DOS32_)
  107.       lReg.ds = segment(pFileName), lReg.dx = offset(pFileName);
  108.    else
  109.       lReg.dx = pointer(pFileName);
  110.    if ( interrupt(0x21,lReg,lRegout) ) {
  111.       lHandle = lRegout.ax;
  112.       // write date to file
  113.       undefine(lReg);
  114.       lReg.ah = 0x57;
  115.       lReg.al = 1;
  116.       lReg.bx = lHandle;
  117.       lTm = localtime(pTime);
  118.       lReg.cx = (lTm.tm_sec / 2)
  119.               | (lTm.tm_min << 5)
  120.               | (lTm.tm_hour << 11);
  121.       lReg.dx = lTm.tm_mday
  122.               | ((lTm.tm_mon+1) << 5)
  123.               | ((lTm.tm_year-80) << 9);
  124.       lSuccess = interrupt(0x21,lReg);
  125.       // close file
  126.       undefine(lReg);
  127.       lReg.ah = 0x3E;
  128.       lReg.bx = lHandle;
  129.       interrupt(0x21,lReg);
  130.    }
  131.    return lSuccess;
  132. }
  133.  
  134.